home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
hope
/
machope.lha
/
hope
/
gets.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-06-28
|
674b
|
42 lines
#include "defs.h"
/*
* Special version of gets to simulate the Unix tty driver for the
* Macintosh (Lightspeed C, anyway).
*/
char *
_gets(line)
char *line;
{
reg char *s;
reg int c;
s = line;
for (;;) {
c = getchar();
switch (c) {
when EOF:
return (char *)0;
when '\n': /* end of the line */
*s = '\0';
return line;
when '\b': /* erase last character */
if (s > line) {
printf(" \b");
s--;
}
else
printf(" ");
when '\025': /* ctrl-U -- erase the line */
printf("\b \b");
while (s > line) {
printf("\b \b");
s--;
}
otherwise:
if (c != '\t' && (c < ' ' || c > '~'))
c = ' ';
*s++ = c;
}
}
}